import java.util.ArrayList;
import java.util.List;
import java.util.Random;

class Ex5 {
	public static void main(String[] args) {
		int n = 10;
		int sum;
		Random random = new Random(System.currentTimeMillis());
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < 6; i++) {
			sum = 0;
			int tmp = 0;
			for (int j = 0; j < 1000; j++) { // 测试1000次求平均
				list.clear(); // 清空集合
				for (int k = 0; k < n; k++) {
					tmp = random.nextInt(n); // 产生一个0 - (n-1)之间的数字
					if (list.contains(tmp)) {
						continue;
					} else {
						list.add(tmp);
						sum++;
					}
				}
			}

			System.out.printf("%-10s", "n=" + n + ":");
			System.out.printf("%-10s", sum * 1.0 / 10000);
			System.out.printf("%-6s", "|x|: ");
			System.out.println(Math.sqrt(n * Math.PI / 2));
			n = n * 10;
		}
	}
}
